home *** CD-ROM | disk | FTP | other *** search
- Path: cad686.sc.intel.com!etse
- From: etse@scdt.intel.com (Eric Tse)
- Newsgroups: comp.lang.c++
- Subject: should operator== and operator= be virtual?
- Date: 30 Jan 1996 02:26:35 GMT
- Organization: Intel Santa Clara Design Technology
- Message-ID: <4ejvkr$btb@itnews.sc.intel.com>
- NNTP-Posting-Host: cad686.sc.intel.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hi,
-
- Should operator==() and operator=() of a class be virtual if the class is
- planned for extensibility? Personally I think in general assignement
- operators should be non-virtual, but I am not sure about equality operator.
- Could anyone helps? Thanks.
-
- class A {
- public:
- A& operator=(const A&);
- virtual bool operator==(const A&) const;
- virtual bool operator!=(const A&) const;
- };
-
- class B : public A {
- public:
- B& operator=(const B&);
-
- virtual bool operator==(const A&) const; // ?
- virtual bool operator!=(const A&) const; // ?
-
- virtual bool operator==(const B&) const; // ?
- virtual bool operator!=(const B&) const; // ?
- };
-
- Eric
-
- --
- -----------------------------------------------------------------------------
- Eric Tse Design Technology, Microprocessor Products Group
- Intel Corporation email: etse@scdt.intel.com
- M/S RN4-38, 2200 Mission College Blvd. phone: (408)765-8453
- Santa Clara, CA 95052 fax: (408)765-5278
- -----------------------------------------------------------------------------
-